#include "tinyexpr.h"
#include <stdio.h>

int main() {
    printf("Testing logical and bitwise operators in TinyExpr:\n\n");
    
    /* Test logical operators */
    printf("Logical operators:\n");
    printf("5 && 3 = %f (expected: 1.0)\n", te_interp("5 && 3", 0));
    printf("0 && 3 = %f (expected: 0.0)\n", te_interp("0 && 3", 0));
    printf("5 || 0 = %f (expected: 1.0)\n", te_interp("5 || 0", 0));
    printf("0 || 0 = %f (expected: 0.0)\n", te_interp("0 || 0", 0));
    printf("!5 = %f (expected: 0.0)\n", te_interp("!5", 0));
    printf("!0 = %f (expected: 1.0)\n", te_interp("!0", 0));
    
    /* Test comparison operators */
    printf("\nComparison operators:\n");
    printf("5 == 5 = %f (expected: 1.0)\n", te_interp("5 == 5", 0));
    printf("5 == 3 = %f (expected: 0.0)\n", te_interp("5 == 3", 0));
    printf("5 != 3 = %f (expected: 1.0)\n", te_interp("5 != 3", 0));
    printf("5 < 10 = %f (expected: 1.0)\n", te_interp("5 < 10", 0));
    printf("5 > 10 = %f (expected: 0.0)\n", te_interp("5 > 10", 0));
    
    /* Test bitwise operators */
    printf("\nBitwise operators:\n");
    printf("5 & 3 = %f (expected: 1.0)\n", te_interp("5 & 3", 0));  // 101 & 011 = 001
    printf("5 | 3 = %f (expected: 7.0)\n", te_interp("5 | 3", 0));  // 101 | 011 = 111
    printf("5 << 1 = %f (expected: 10.0)\n", te_interp("5 << 1", 0));  // 101 << 1 = 1010
    printf("5 >> 1 = %f (expected: 2.0)\n", te_interp("5 >> 1", 0));  // 101 >> 1 = 010
    
    /* Test complex expressions */
    printf("\nComplex expressions:\n");
    printf("(5 > 3) && (2 < 4) = %f (expected: 1.0)\n", te_interp("(5 > 3) && (2 < 4)", 0));
    printf("(5 & 3) | (2 << 1) = %f (expected: 5.0)\n", te_interp("(5 & 3) | (2 << 1)", 0));
    printf("!(0) && (5 == 5) = %f (expected: 1.0)\n", te_interp("!(0) && (5 == 5)", 0));
    
    return 0;
}